<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>CANopenNode: OD storage</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">CANopenNode
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__CO__socketCAN__OD__storage.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#files">Files</a> &#124;
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">OD storage<div class="ingroups"><a class="el" href="group__CO__socketCAN.html">socketCAN</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>Object Dictionary storage implementation for CANopenNode on Linux.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="files"></a>
Files</h2></td></tr>
<tr class="memitem:CO__OD__storage_8h"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="CO__OD__storage_8h.html">CO_OD_storage.h</a></td></tr>
<tr class="memdesc:CO__OD__storage_8h"><td class="mdescLeft">&#160;</td><td class="mdescRight">CANopen Object Dictionary storage object for Linux SocketCAN. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structCO__OD__storage__t.html">CO_OD_storage_t</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Object Dictionary storage object.  <a href="structCO__OD__storage__t.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga4a5e807a83eeab172bb3b0aeb6fa92c2"><td class="memItemLeft" align="right" valign="top"><a id="ga4a5e807a83eeab172bb3b0aeb6fa92c2"></a>
<a class="el" href="group__CO__SDOserver.html#ga7587ddcf798747fe6d97d03bf1bf2979">CO_SDO_abortCode_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CO__socketCAN__OD__storage.html#ga4a5e807a83eeab172bb3b0aeb6fa92c2">CO_ODF_1010</a> (<a class="el" href="structCO__ODF__arg__t.html">CO_ODF_arg_t</a> *ODF_arg)</td></tr>
<tr class="memdesc:ga4a5e807a83eeab172bb3b0aeb6fa92c2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Callback for use inside <a class="el" href="group__CO__SDOserver.html#gab433430abe125bb16c08e7be3e034985">CO_OD_configure()</a> function for OD object 1010. <br /></td></tr>
<tr class="separator:ga4a5e807a83eeab172bb3b0aeb6fa92c2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga059fcd46d8b15caf86c57d541a09576a"><td class="memItemLeft" align="right" valign="top"><a id="ga059fcd46d8b15caf86c57d541a09576a"></a>
<a class="el" href="group__CO__SDOserver.html#ga7587ddcf798747fe6d97d03bf1bf2979">CO_SDO_abortCode_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CO__socketCAN__OD__storage.html#ga059fcd46d8b15caf86c57d541a09576a">CO_ODF_1011</a> (<a class="el" href="structCO__ODF__arg__t.html">CO_ODF_arg_t</a> *ODF_arg)</td></tr>
<tr class="memdesc:ga059fcd46d8b15caf86c57d541a09576a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Callback for use inside <a class="el" href="group__CO__SDOserver.html#gab433430abe125bb16c08e7be3e034985">CO_OD_configure()</a> function for OD object 1011. <br /></td></tr>
<tr class="separator:ga059fcd46d8b15caf86c57d541a09576a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7f6124c9079807bc2f8f3d860571ccec"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CO__socketCAN__OD__storage.html#ga7f6124c9079807bc2f8f3d860571ccec">CO_OD_storage_saveSecure</a> (<a class="el" href="group__CO__dataTypes.html#gaba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *odAddress, <a class="el" href="group__CO__dataTypes.html#ga33594304e786b158f3fb30289278f5af">uint32_t</a> odSize, char *filename)</td></tr>
<tr class="memdesc:ga7f6124c9079807bc2f8f3d860571ccec"><td class="mdescLeft">&#160;</td><td class="mdescRight">Save memory block to a file.  <a href="#ga7f6124c9079807bc2f8f3d860571ccec">More...</a><br /></td></tr>
<tr class="separator:ga7f6124c9079807bc2f8f3d860571ccec"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga63b392fa7eb2bdc92ecd2f1ff6f4ced0"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CO__socketCAN__OD__storage.html#ga63b392fa7eb2bdc92ecd2f1ff6f4ced0">CO_OD_storage_restoreSecure</a> (char *filename)</td></tr>
<tr class="memdesc:ga63b392fa7eb2bdc92ecd2f1ff6f4ced0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Remove OD storage file.  <a href="#ga63b392fa7eb2bdc92ecd2f1ff6f4ced0">More...</a><br /></td></tr>
<tr class="separator:ga63b392fa7eb2bdc92ecd2f1ff6f4ced0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5a26b63e7222b058c6024e54c6e0d5cd"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CO__driver.html#ga1cb2d3466eb0c6d267f3b5ff1a0d9532">CO_ReturnError_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CO__socketCAN__OD__storage.html#ga5a26b63e7222b058c6024e54c6e0d5cd">CO_OD_storage_init</a> (<a class="el" href="structCO__OD__storage__t.html">CO_OD_storage_t</a> *odStor, <a class="el" href="group__CO__dataTypes.html#gaba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *odAddress, <a class="el" href="group__CO__dataTypes.html#ga33594304e786b158f3fb30289278f5af">uint32_t</a> odSize, char *filename)</td></tr>
<tr class="memdesc:ga5a26b63e7222b058c6024e54c6e0d5cd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize OD storage object and load data from file.  <a href="#ga5a26b63e7222b058c6024e54c6e0d5cd">More...</a><br /></td></tr>
<tr class="separator:ga5a26b63e7222b058c6024e54c6e0d5cd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9381d4f670cef9068efaf7d42097de2f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CO__driver.html#ga1cb2d3466eb0c6d267f3b5ff1a0d9532">CO_ReturnError_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CO__socketCAN__OD__storage.html#ga9381d4f670cef9068efaf7d42097de2f">CO_OD_storage_autoSave</a> (<a class="el" href="structCO__OD__storage__t.html">CO_OD_storage_t</a> *odStor, <a class="el" href="group__CO__dataTypes.html#ga33594304e786b158f3fb30289278f5af">uint32_t</a> timer1usDiff, <a class="el" href="group__CO__dataTypes.html#ga33594304e786b158f3fb30289278f5af">uint32_t</a> delay_us)</td></tr>
<tr class="memdesc:ga9381d4f670cef9068efaf7d42097de2f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Automatically save memory block if differs from file.  <a href="#ga9381d4f670cef9068efaf7d42097de2f">More...</a><br /></td></tr>
<tr class="separator:ga9381d4f670cef9068efaf7d42097de2f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6c51a86516ff7e128873f6cf1fdef5eb"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CO__socketCAN__OD__storage.html#ga6c51a86516ff7e128873f6cf1fdef5eb">CO_OD_storage_autoSaveClose</a> (<a class="el" href="structCO__OD__storage__t.html">CO_OD_storage_t</a> *odStor)</td></tr>
<tr class="memdesc:ga6c51a86516ff7e128873f6cf1fdef5eb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Closes file opened by CO_OD_storage_autoSave.  <a href="#ga6c51a86516ff7e128873f6cf1fdef5eb">More...</a><br /></td></tr>
<tr class="separator:ga6c51a86516ff7e128873f6cf1fdef5eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Object Dictionary storage implementation for CANopenNode on Linux. </p>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga9381d4f670cef9068efaf7d42097de2f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9381d4f670cef9068efaf7d42097de2f">&#9670;&nbsp;</a></span>CO_OD_storage_autoSave()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__CO__driver.html#ga1cb2d3466eb0c6d267f3b5ff1a0d9532">CO_ReturnError_t</a> CO_OD_storage_autoSave </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structCO__OD__storage__t.html">CO_OD_storage_t</a> *&#160;</td>
          <td class="paramname"><em>odStor</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__CO__dataTypes.html#ga33594304e786b158f3fb30289278f5af">uint32_t</a>&#160;</td>
          <td class="paramname"><em>timer1usDiff</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__CO__dataTypes.html#ga33594304e786b158f3fb30289278f5af">uint32_t</a>&#160;</td>
          <td class="paramname"><em>delay_us</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Automatically save memory block if differs from file. </p>
<p>Should be called cyclically by program. It first verifies, if memory block differs from file and if it does, it saves it to file with two additional CRC bytes. File remains opened.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">odStor</td><td>OD storage object. </td></tr>
    <tr><td class="paramname">timer1usDiff</td><td>Time difference in microseconds since last call. </td></tr>
    <tr><td class="paramname">delay_us</td><td>Delay (inhibit) time between writes to disk in microseconds (60000 for example).</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><a class="el" href="group__CO__driver.html#ga1cb2d3466eb0c6d267f3b5ff1a0d9532" title="Return values of some CANopen functions. ">CO_ReturnError_t</a>: CO_ERROR_NO, CO_ERROR_DATA_CORRUPT (Data in file corrupt), CO_ERROR_ILLEGAL_ARGUMENT or CO_ERROR_OUT_OF_MEMORY (malloc failed). </dd></dl>

</div>
</div>
<a id="ga6c51a86516ff7e128873f6cf1fdef5eb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga6c51a86516ff7e128873f6cf1fdef5eb">&#9670;&nbsp;</a></span>CO_OD_storage_autoSaveClose()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void CO_OD_storage_autoSaveClose </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structCO__OD__storage__t.html">CO_OD_storage_t</a> *&#160;</td>
          <td class="paramname"><em>odStor</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Closes file opened by CO_OD_storage_autoSave. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">odStor</td><td>OD storage object. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga5a26b63e7222b058c6024e54c6e0d5cd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5a26b63e7222b058c6024e54c6e0d5cd">&#9670;&nbsp;</a></span>CO_OD_storage_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__CO__driver.html#ga1cb2d3466eb0c6d267f3b5ff1a0d9532">CO_ReturnError_t</a> CO_OD_storage_init </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structCO__OD__storage__t.html">CO_OD_storage_t</a> *&#160;</td>
          <td class="paramname"><em>odStor</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__CO__dataTypes.html#gaba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *&#160;</td>
          <td class="paramname"><em>odAddress</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__CO__dataTypes.html#ga33594304e786b158f3fb30289278f5af">uint32_t</a>&#160;</td>
          <td class="paramname"><em>odSize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>filename</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize OD storage object and load data from file. </p>
<p>Called after program startup. Load storage file and copy data to Object Dictionary variables.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">odStor</td><td>This object will be initialized. </td></tr>
    <tr><td class="paramname">odAddress</td><td>Address of the memory block from Object dictionary, where data will be copied. </td></tr>
    <tr><td class="paramname">odSize</td><td>Size of the above memory block. </td></tr>
    <tr><td class="paramname">filename</td><td>Name of the file, where data are stored.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><a class="el" href="group__CO__driver.html#ga1cb2d3466eb0c6d267f3b5ff1a0d9532" title="Return values of some CANopen functions. ">CO_ReturnError_t</a>: CO_ERROR_NO, CO_ERROR_DATA_CORRUPT (Data in file corrupt), CO_ERROR_CRC (CRC from MBR does not match the CRC of OD_ROM block in file), CO_ERROR_ILLEGAL_ARGUMENT or CO_ERROR_OUT_OF_MEMORY (malloc failed). </dd></dl>

</div>
</div>
<a id="ga63b392fa7eb2bdc92ecd2f1ff6f4ced0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga63b392fa7eb2bdc92ecd2f1ff6f4ced0">&#9670;&nbsp;</a></span>CO_OD_storage_restoreSecure()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int CO_OD_storage_restoreSecure </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>filename</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Remove OD storage file. </p>
<p>Function renames current file to filename.old, then creates empty file and writes two bytes "-\n" to it. When program will start next time, default values are used for Object Dictionary. In case of error in renaming to .old it keeps the original file and returns error.</p>
<p>Writing data to file is secured with mutex CO_LOCK_OD.</p>
<p>Function is used with CANopen OD object at index 1011.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">filename</td><td>Name of the file.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 on success, -1 on error. </dd></dl>

</div>
</div>
<a id="ga7f6124c9079807bc2f8f3d860571ccec"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga7f6124c9079807bc2f8f3d860571ccec">&#9670;&nbsp;</a></span>CO_OD_storage_saveSecure()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int CO_OD_storage_saveSecure </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__CO__dataTypes.html#gaba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *&#160;</td>
          <td class="paramname"><em>odAddress</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__CO__dataTypes.html#ga33594304e786b158f3fb30289278f5af">uint32_t</a>&#160;</td>
          <td class="paramname"><em>odSize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>filename</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Save memory block to a file. </p>
<p>Function renames current file to filename.old, copies contents from odAddress to filename, adds two bytes of CRC code. It then verifies the written file and in case of errors sets back the old file and returns error.</p>
<p>Function is used with CANopen OD object at index 1010.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">odAddress</td><td>Address of the memory block, which will be stored. </td></tr>
    <tr><td class="paramname">odSize</td><td>Size of the above memory block. </td></tr>
    <tr><td class="paramname">filename</td><td>Name of the file, where data will be stored.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 on success, -1 on error. </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Tue Jun 9 2020 17:29:32 for CANopenNode by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
